<html>

<head>
<title>Swing JDialog Wizard</title>
<link href="../../../book.css" rel="stylesheet" type="text/css" />
</head>

<body>

<h1>Swing JDialog Wizard</h1>

<table border="0" cellpadding="0" cellspacing="0" width="720">
  <tr>
    <td>
        <img src="images/wizard_swing_jdialog0.gif" align="left" hspace="10">Subclasses of the Swing <b>JDialog</b> class can be
              created using the <b>Swing JDialog</b>&nbsp; wizard. The wizard can be
              selected from the drop down wizard menu or from the
              Eclipse <b>New</b> wizard.
              <p>To use the wizard, select the project source folder and package
              to contain the class. Then enter the class name and hit the <b>Finish</b>
              button.</td>
  </tr>
  <tr>
    <td>
      <br>
		<img src="images/wizard_swing_jdialog1.gif">&nbsp; 
		<img src="images/wizard_swing_jdialog2.gif"></td>
  </tr>
  <tr>
    <td>
      <p><br>
		The wizard generates the following code including a <b>main()</b> method.</p>
      <font SIZE="2" COLOR="#7f0055"><b>
		<blockquote>
			<p><font face="Courier">import</font></b></font><font face="Courier" SIZE="2"> 
		javax.swing.JDialog;</font><font SIZE="2" COLOR="#7f0055"><b><font face="Courier"><br>
			<br>
			public</font></b></font><font face="Courier"><font SIZE="2"> </font>
			<font SIZE="2" COLOR="#7f0055"><b>class</b></font><font SIZE="2"> 
		SwingJDialogTest </font><font SIZE="2" COLOR="#7f0055"><b>extends</b></font></font><font face="Courier" SIZE="2"> 
		JDialog {<br>
			</font><font face="Courier"><font SIZE="2" COLOR="#7f0055">
			<b>&nbsp;&nbsp;&nbsp;
			public</b></font><font SIZE="2"> </font>
			<font SIZE="2" COLOR="#7f0055"><b>static</b></font><font SIZE="2">
			</font><font SIZE="2" COLOR="#7f0055"><b>void</b></font></font><font face="Courier" SIZE="2"> 
			main(String[] args) {<br>
			</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;
			&nbsp;&nbsp;&nbsp; try</b></font><font face="Courier" SIZE="2"> 
				{<br>
			</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			&nbsp;&nbsp;&nbsp;
			</b></font><font face="Courier" SIZE="2">SwingJDialogTest dialog =
			</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>new</b></font><font face="Courier" SIZE="2"> 
					SwingJDialogTest();<br>
			</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			</b></font><font face="Courier" SIZE="2">dialog.setDefaultCloseOperation(JDialog.</font><font SIZE="2" COLOR="#0000c0" face="Courier"><i>DISPOSE_ON_CLOSE</i></font><font face="Courier" SIZE="2">);<br>
			</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			</b></font><font face="Courier" SIZE="2">dialog.setVisible(</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>true</b></font><font face="Courier" SIZE="2">);<br>
			</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			</b></font><font face="Courier" SIZE="2">} </font>
			<font SIZE="2" COLOR="#7f0055" face="Courier"><b>catch</b></font><font face="Courier" SIZE="2"> 
				(Exception e) {<br>
			</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			</b></font><font face="Courier" SIZE="2">e.printStackTrace();<br>
			</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			</b></font><font face="Courier" SIZE="2">}<br>
			</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;
			</b></font><font face="Courier" SIZE="2">}<br></font>
			<font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp; 
			public</b></font><font face="Courier" SIZE="2"> 
			SwingJDialogTest() {<br>
			</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;
			&nbsp;&nbsp;&nbsp;
			</b></font><font face="Courier" SIZE="2">setBounds(100, 100, 450, 300);<br>
			</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;
			</b></font><font SIZE="2"><font face="Courier">}<br>
			}</font></p>
		</blockquote>
		</font>
      <p>If the <b>Generate JDialog with OK and Cancel buttons</b> option is 
		checked, the following code is generated which adds an <b>OK</b> and <b>
		Cancel</b> button</p><font SIZE="2">
		<blockquote>
			<dl>
				<dd></font><font face="Courier"><font SIZE="2" COLOR="#7f0055">
				<b>private</b></font><font SIZE="2"> </font>
				<font SIZE="2" COLOR="#7f0055"><b>final</b></font><font SIZE="2"> 
			JPanel </font><font SIZE="2" COLOR="#0000c0">m_contentPanel</font></font><font SIZE="2"><font face="Courier">;</font></dd>
				</font><font FACE="Courier" SIZE="2">
				<dd>...</dd>
			</font><font SIZE="2">
				<dd></font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>public</b></font><font face="Courier" SIZE="2"> 
			SwingJDialogTest() {<br>
				</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;
				</b></font><font face="Courier" SIZE="2">setBounds(100, 100, 450, 300);<br>
				</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;
				</b></font><font face="Courier" SIZE="2">getContentPane().setLayout(</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>new</b></font><font face="Courier" SIZE="2"> 
				BorderLayout());<br>
				</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;
				</b></font><font face="Courier"><font SIZE="2" COLOR="#0000c0">m_contentPanel</font><font SIZE="2"> = 
				</font><font SIZE="2" COLOR="#7f0055"><b>new</b></font></font><font face="Courier" SIZE="2"> 
				JPanel();<br>
				</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;
				</b></font><font face="Courier"><font SIZE="2" COLOR="#0000c0">m_contentPanel</font><font SIZE="2">.setLayout(</font><font SIZE="2" COLOR="#7f0055"><b>new</b></font></font><font face="Courier" SIZE="2"> 
				FlowLayout());<br>
				</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;
				</b></font><font face="Courier"><font SIZE="2" COLOR="#0000c0">m_contentPanel</font><font SIZE="2">.setBorder(</font><font SIZE="2" COLOR="#7f0055"><b>new</b></font></font><font face="Courier" SIZE="2"> 
				EmptyBorder(5, 5, 5, 5));<br>
				</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;
				</b></font><font face="Courier" SIZE="2">getContentPane().add(</font><font face="Courier"><font SIZE="2" COLOR="#0000c0">m_contentPanel</font><font SIZE="2">, 
				BorderLayout.</font><font SIZE="2" COLOR="#0000c0"><i>CENTER</i></font></font><font face="Courier" SIZE="2">);<br>
				</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;
				</b></font><font face="Courier" SIZE="2">JPanel buttonPane =
				</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>new</b></font><font face="Courier" SIZE="2"> 
				JPanel();<br>
				</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;
				</b></font><font face="Courier" SIZE="2">buttonPane.setLayout(</font><font face="Courier"><font SIZE="2" COLOR="#7f0055"><b>new</b></font><font SIZE="2"> 
				FlowLayout(FlowLayout.</font><font SIZE="2" COLOR="#0000c0"><i>RIGHT</i></font></font><font face="Courier" SIZE="2">));<br>
				</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;
				</b></font><font face="Courier" SIZE="2">JButton okButton =
				</font><font face="Courier"><font SIZE="2" COLOR="#7f0055"><b>new</b></font><font SIZE="2"> 
				JButton(</font><font SIZE="2" COLOR="#2a00ff">&quot;OK&quot;</font></font><font face="Courier" SIZE="2">);<br>
				</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;
				</b></font><font face="Courier" SIZE="2">getRootPane().setDefaultButton(okButton);<br>
				</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;
				</b></font><font face="Courier" SIZE="2">okButton.setActionCommand(</font><font SIZE="2" COLOR="#2a00ff" face="Courier">&quot;OK&quot;</font><font face="Courier" SIZE="2">);<br>
				</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;
				</b></font><font face="Courier" SIZE="2">buttonPane.add(okButton);<br>
				</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;
				</b></font><font face="Courier" SIZE="2">JButton cancelButton =
				</font><font face="Courier"><font SIZE="2" COLOR="#7f0055"><b>new</b></font><font SIZE="2"> 
				JButton(</font><font SIZE="2" COLOR="#2a00ff">&quot;Cancel&quot;</font></font><font face="Courier" SIZE="2">);<br>
				</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;
				</b></font><font face="Courier" SIZE="2">cancelButton.setActionCommand(</font><font SIZE="2" COLOR="#2a00ff" face="Courier">&quot;Cancel&quot;</font><font face="Courier" SIZE="2">);<br>
				</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;
				</b></font><font face="Courier" SIZE="2">buttonPane.add(cancelButton);<br>
				</font><font SIZE="2" COLOR="#7f0055" face="Courier"><b>&nbsp;&nbsp;&nbsp;
				</b></font><font face="Courier" SIZE="2">getContentPane().add(buttonPane, 
				BorderLayout.</font><font SIZE="2" COLOR="#0000c0" face="Courier"><i>SOUTH</i></font><font SIZE="2"><font face="Courier">);</font></dd>
				<dd><font face="Courier">}</font></dd>
			</dl>
		</blockquote>
		</font>
	<p>When editing Swing JDialogs, all of the standard Swing layouts,
      containers, widgets and menus are available. Custom or third party
      controls may be added via the <b>
		<a href="../../../com.instantiations.designer.doc.user/html/userinterface/palette.html">Choose 
		Component</a> </b> command. You may also
      preview your dialog using different look and feels using the drop down look
      and feel list in the toolbar. </p>
    </td>
  </tr>
</table>
</body>
</html>
